package czx.wt.system.controller;

import org.wf.jwtp.provider.Token;
import org.wf.jwtp.util.SubjectUtil;

import javax.servlet.http.HttpServletRequest;

/**
 * @Author: ChenZhiXiang
 * @Date: 2019/6/20 20:49
 * @Description: controller基类
 */
public class BaseController {

    /**
     * 获取Token
     * @param request
     * @return
     */
    public Token getToken(HttpServletRequest request){
        return SubjectUtil.getToken(request);
    }

    /**
     * 获取用户编码
     * @param request
     * @return
     */
    public Integer getUserId(HttpServletRequest request){
        Token token = getToken(request);
        return token == null ? null : Integer.valueOf(token.getUserId());
    }
}
